import pytest,os,time,logging,yagmail

t = time.strftime('%Y%m%d%H%M%S')
def mkdir_log():
    log_cat = logging.basicConfig(level=logging.DEBUG,
                                  format='%(message)s %(levelname)s %(lineno)s %(filename)s %(asctime)s',
                                  filemode='w+',
                                  filename='../Log/'+t+'.log')
    return log_cat

def send_email(file):
    email = yagmail.SMTP(user='1847537889@qq.com',password='liavbivsorckhacj',host='smtp.qq.com')
    email.send(to='1847537889@qq.com',subject='酒仙网系统Web Ui自动化测试报告+当前的日志',contents=file)

if __name__ == '__main__':
    mkdir_log()
    pytest.main(['../TestCase/test_case.py','-s','--alluredir=../Report/allure-result'])
    os.system(f'allure generate ../Report/allure-result -o ../Report/{t}-resport --clean')
    send_email(['../Log/'+t+'.log','../Report/'+t+'-resport/index.html'])